<script setup lang="ts">
import LuckySheet from '@/components/LuckySheet.vue'
import { nextTick, ref } from 'vue'

const luckysheetRef = ref()

// const handleConfirm = () => {
//   // 获取文件
//   luckysheetRef.value.downloadExcel().then((res: any) => {
//     console.log(res) //这就是file文件，可以在这里传给后端
//   })
// }

;(async () => {
  fetch('http://localhost:5173/%E7%94%9F%E6%88%90%E5%86%85%E5%AE%B9%E6%B5%8B%E8%AF%95.xlsx').then(
    async (res) => {
      console.log()
      const blob = await res.blob()
      const file1 = new File([blob], 'test1.xlsx', {
        type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
        lastModified: Date.now(),
      })
      console.log(file1)

      nextTick(() => {
        try {
          luckysheetRef.value.loadExcel(file1)
        } catch (error) {
          // state.fillVisible = false
        }
      })
    },
  )
})()

// const file1 = new File(
//   ['http://localhost:5173/%E7%94%9F%E6%88%90%E5%86%85%E5%AE%B9%E6%B5%8B%E8%AF%95.xlsx'],
//   'test1',
//   {
//     type: 'application/json',
//     lastModified: Date.now(),
//   },
// )
// console.log(file1)
</script>

<template>
  <LuckySheet ref="luckysheetRef"></LuckySheet>
</template>

<style scoped>
/* header {
  line-height: 1.5;
  max-height: 100vh;
}

.logo {
  display: block;
  margin: 0 auto 2rem;
}

nav {
  width: 100%;
  font-size: 12px;
  text-align: center;
  margin-top: 2rem;
}

nav a.router-link-exact-active {
  color: var(--color-text);
}

nav a.router-link-exact-active:hover {
  background-color: transparent;
}

nav a {
  display: inline-block;
  padding: 0 1rem;
  border-left: 1px solid var(--color-border);
}

nav a:first-of-type {
  border: 0;
}

@media (min-width: 1024px) {
  header {
    display: flex;
    place-items: center;
    padding-right: calc(var(--section-gap) / 2);
  }

  .logo {
    margin: 0 2rem 0 0;
  }

  header .wrapper {
    display: flex;
    place-items: flex-start;
    flex-wrap: wrap;
  }

  nav {
    text-align: left;
    margin-left: -1rem;
    font-size: 1rem;

    padding: 1rem 0;
    margin-top: 1rem;
  }
} */
</style>
